package com.erp.order.dn.service.spring;

import com.erp.hr.base.util.CommonUtils;
import com.erp.order.dn.dao.DeliveryNoteHeadDao;
import com.erp.order.dn.dao.model.DeliveryNoteHead;
import com.erp.order.dn.dao.model.DeliveryNoteHeadCO;
import com.erp.order.dn.service.DeliveryNoteHeadService;
import org.redragon.framework.hibernate.model.Pages;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * @author zhoupan
 * @date 2021/4/9 11:24
 * @info
 */
@Service
@Transactional(rollbackFor=Exception.class)
public class DeliveryNoteHeadServiceImpl implements DeliveryNoteHeadService {
    @Autowired
    private DeliveryNoteHeadDao deliveryNoteHeadDao;

    @Override
    public void insertDataObject(DeliveryNoteHead deliveryNoteHead) {
        deliveryNoteHeadDao.insertDataObject(deliveryNoteHead);
    }

    @Override
    public void updateDataObject(DeliveryNoteHead deliveryNoteHead) {

    }

    @Override
    public void insertOrUpdateDataObject(DeliveryNoteHead deliveryNoteHead) {

    }

    @Override
    public void deleteDataObject(DeliveryNoteHead deliveryNoteHead) {

    }

    @Override
    public List<DeliveryNoteHead> getDataObjects() {
        return null;
    }

    @Override
    public DeliveryNoteHead getDataObject(int i) {
        return null;
    }

    @Override
    public DeliveryNoteHead getDataObject(String s) {
        return null;
    }

    @Override
    public List<DeliveryNoteHead> getDataObjects(DeliveryNoteHeadCO deliveryNoteHeadCO) {
        return null;
    }

    @Override
    public List<DeliveryNoteHead> getDataObjects(Pages pages) {
        return null;
    }

    @Override
    public List<DeliveryNoteHead> getDataObjects(Pages pages, DeliveryNoteHeadCO deliveryNoteHeadCO) {
        return deliveryNoteHeadDao.getDataObjects(pages, deliveryNoteHeadCO);
    }

    @Override
    public List<Map<String, Object>> getDataObjectsArray(Pages pages, DeliveryNoteHeadCO deliveryNoteHeadCO) {
        return null;
    }

    @Override
    public List<DeliveryNoteHead> getDataObjectsForDataAuth(String s, Pages pages, DeliveryNoteHeadCO deliveryNoteHeadCO) {
        return null;
    }

    @Override
    public DeliveryNoteHead getDataObjectByCode(String headCode) {
        return deliveryNoteHeadDao.getDataObjectByCode(headCode);
    }

    @Override
    public String getNewDeliveryCode() {
        Integer num = deliveryNoteHeadDao.getNewDeliveryCode() + 1;
        String suffix = num.toString();
        StringBuilder result = new StringBuilder();
        for (int i = 0; i < CommonUtils.PURCHASING_REQUISITION_LENGRH - suffix.length(); i ++) {
            result.append("0");
        }
        result.append(suffix);
        return result.toString();
    }
}
